package base.day26.tcp;

import java.io.*;
import java.net.Socket;

public class SendDemo2 {
    public static void main(String[] args) throws IOException {
        Socket s=new Socket("127.0.0.2",10006);
        OutputStream os = s.getOutputStream();
        os.write("发送数据".getBytes());

        s.shutdownOutput();  //仅仅关闭输出流并，写一个结束标记

//        InputStream is = s.getInputStream();
//        int b;
//        while ((b=is.read())!=1){
//            System.out.println((char)b);
//        }
        BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream()));
        String str;
        while ((str=br.readLine())!=null){
            System.out.println(str );
        }

        os.close();
        br.close();
        s.close();

    }


}
